package com.example.newproject_overseas.components

import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.compose.rememberNavController

@Composable
fun ShowDialog(
    title:String ,
    confirmText:String ,
    dismissText:String ,
    onConfirm: () -> Unit,
    onDismiss: () -> Unit
) {
    val context = LocalContext.current

    AlertDialog(
        onDismissRequest = onDismiss,
        title = {
            MaterialTheme {
                Text(text = "提示")
            }
        },
        text = {
            MaterialTheme {
                Text(
                    text = title ,
                    color = Color.Black
                )
            }
        },
        confirmButton = {
            Button(
                onClick = {
                    onConfirm()
                    // Do something on confirm button click
                },
                colors = ButtonDefaults.buttonColors(containerColor = Color(0xFFFFCC00), contentColor = Color.White)
            ) {
                MaterialTheme {
                    Text(text = confirmText)
                }
            }
        },
        dismissButton = {
            Button(
                onClick = {
                    onDismiss()
                    // Do something on dismiss button click
                },
                colors = ButtonDefaults.buttonColors(containerColor = Color(0xFFDA2525), contentColor = Color.White)
            ) {
                MaterialTheme {
                    Text(text = dismissText)
                }
            }
        }
    )
}


@Preview
@Composable
fun ShowDialogCmpPreview() {
    var showDialog by remember { mutableStateOf(false) }
    ShowDialog(
        title = "您有表单尚未完成!",
        confirmText = "确定",
        dismissText = "取消",
        onConfirm = {

        },
        onDismiss = { showDialog = false }
    );
}

